package com.bruce.codeFactory.Thread.designMode.ThreadWoker;

import java.util.Random;

/**
 * @author luotuan
 * @Description
 * @create 2019-03-13 21:50
 **/
public class WorkerThread extends Thread {
    private final Channel channel;
    private static final Random RANDOM = new Random(System.currentTimeMillis());

    public WorkerThread(String name, Channel channel) {
        super(name);
        this.channel = channel;
    }

    @Override
    public void run() {
        while (true){
            this.channel.take().execute();
            try {
                Thread.sleep(RANDOM.nextInt(1000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
